package com.gym.openapi.web.controller;

import com.gym.openapi.common.ResponseResult;
import com.gym.openapi.common.ResultTable;
import com.gym.openapi.entity.Customer;
import com.gym.openapi.services.CustomerServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ming
 * 2021/11/26
 * description:客户管理
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerServices customerServices;

    /**
     * @author:ming
     * @Date: 2021/11/26
     * @description:页面分页显示
     */
    @RequestMapping("/table")
    public ResultTable getTable(Integer page, Integer limit, String name, Integer state) {
        return customerServices.table(page, limit, name, state);
    }

    /**
     * @author:ming
     * @Date: 2021/11/26
     * @description:删除批量
     */
    @RequestMapping("/del")
    public ResponseResult del(Integer[] ids) {
        return customerServices.del(ids);
    }

    /**
     * @author:ming
     * @Date: 2021/11/26
     * @description:添加数据
     */
    @RequestMapping("/add")
    public ResponseResult add(Customer c) {
        return customerServices.add(c);
    }

    /**
     * @author:ming
     * @Date: 2021/11/26
     * @description:修改数据
     */
    @RequestMapping("/update")
    public ResponseResult update(Customer c) {
        return customerServices.update(c);
    }

    @RequestMapping("tree")
    public List<Customer> gettree() {
        return customerServices.getAll();
    }

}
